package com.hl.card.modular.pack.controller;

import com.hl.card.common.util.CommonUtil;
import com.hl.card.common.util.ResponseData;
import com.hl.card.modular.pack.service.DisMemberProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 合伙人签约进度控制器
 * 
 * @author 袁伟
 *
 */
@RestController
@RequestMapping("/api/disMemberProcess")
public class MemberProcessController {
	@Autowired
	private DisMemberProcessService disMemberProcessService;
	@Autowired
	private ResponseData responseData;
	@RequestMapping("/searchDisMemberProcess.do")
	public ResponseData searchDisMemberProcess(String user_id) {
		responseData.setData(null);
		if (CommonUtil.isEmpty(user_id)) {
			responseData.setStatus("0");
			responseData.setMsg("用户ID不能为空");
			return responseData;
		}
	
		return disMemberProcessService.searchDisMemberProcess(user_id);
	}
	
	@RequestMapping("/addLogisticsInfo.do")
	public ResponseData addLogisticsInfo(String r_logistics_company,String r_logistics_no,String user_id) {
		responseData.setData(null);
		if (CommonUtil.isEmpty(user_id)) {
			responseData.setStatus("0");
			responseData.setMsg("用户ID不能为空");
			return responseData;
		}
		if (CommonUtil.isEmpty(r_logistics_company)) {
			responseData.setStatus("0");
			responseData.setMsg("回寄物流公司不能为空");
			return responseData;
		}
		
		int compay_length= CommonUtil.getStrLength(r_logistics_company);
		if(compay_length<2||compay_length>15)
		{
			responseData.setStatus("0");
			responseData.setMsg("回寄物流公司只能是2-15个字符");
			return responseData;
		}
		if (CommonUtil.isEmpty(r_logistics_no)) {
			responseData.setStatus("0");
			responseData.setMsg("回寄物流单号不能为空");
			return responseData;
		}
		int logistics_no_length= CommonUtil.getStrLength(r_logistics_no);
		if(logistics_no_length<8||logistics_no_length>20)
		{
			responseData.setStatus("0");
			responseData.setMsg("回寄物流单号只能是8-20个字符");
			return responseData;
		}
		return disMemberProcessService.addLogisticsInfo(r_logistics_company,r_logistics_no,user_id);
	}
}
